package com.monitor.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.JfzCarTypeMapper;
import com.monitor.entity.JfzCarType;
import com.monitor.service.JfzCarTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class JfzCarTypeServiceImpl extends ServiceImpl<JfzCarTypeMapper, JfzCarType> implements JfzCarTypeService {
	@Resource
	private JfzCarTypeMapper jfzCarTypeMapper;
	
	@Override
	public Integer updateType(int carId, int type) {
		// TODO Auto-generated method stub
		try {
			JfzCarType ct=jfzCarTypeMapper.selectByCarId(carId);
			int count=0;
			if(ct!=null) {
				count=jfzCarTypeMapper.updateType(ct);
			}else {
				ct=new JfzCarType();
				ct.setType(type);
				count=jfzCarTypeMapper.insert1(ct);
			}
			return count;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	}

}
